package com.superview.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.nio.charset.Charset;

public class PhoneRuntime {
	private String pyPath = "python";
	private String funcPath = "main_chaowei.py";
	
	public String GetPhoneTimes(String chinese) {
		try {
			String[] ars = new String[] { getPyPath(), getFuncPath(),chinese};
			Process pr;
	        pr = Runtime.getRuntime().exec(ars,null, new File("chaowei-speech-txt-align"));
	      //用输入输出流来截取结果
            BufferedReader in = new BufferedReader(new InputStreamReader(pr.getInputStream(),Charset.forName("GBK")));
            String line = null;
            String result = null;
            while ((line = in.readLine()) != null) {
                result = line;
            }
            in.close();
	        pr.waitFor();
	        return result;
		} catch (Throwable t) {
			t.printStackTrace();
		}
		return null;
	}

	public String getPyPath() {
		return pyPath;
	}

	public String getFuncPath() {
		return funcPath;
	}
	
}
